function newReceipt() {
	greyLayer.open();
	//每次打开初始化动态生成的表格
	win.window('open');
	form.form('clear');	
	form.url = '/pxglxt/return_receipt/save';
	$('#receipt_id').attr('value',rid);
	$('#receipt_time').attr('value',rtime);
	$('#creater').attr('value',realName);
}

function editReceipt() {
	var row = grid.datagrid('getSelected');
	if (row) {
		greyLayer.open();
		win.window('open');
		form.form('load', '/pxglxt/return_receipt/getReturn_receipt/' + row.id);
		form.url = '/pxglxt/return_receipt/update/' + row.id;
	} else {
		sys_alert('错误提示', '选择一个收据', 'error');
	}
}
function saveReceipt() {
	if (form.form('validate')) {
		form.form('submit', {
					url : form.url,
					success : function(data) {
						try {
							eval('data=' + data);
							if (data.success) {
								grid.datagrid('reload');
								win.window('close');
								greyLayer.close();
							} else {
								sys_alert('错误提示', data.msg, 'error');
							}
						} catch (e) {
							sys_alert('系统异常', data, 'error');
						}
					}
				});
	}
}
function delReceipt() {
	// 删除前询问
	$.messager.confirm("用户确认", "确认要删除该收款单？", function(r) {
				if (r) {
					var row = grid.datagrid('getSelected');
					if (row) {
						form.url = '/pxglxt/return_receipt/destroy/' + row.id;
						form.form('submit', {
									url : form.url,
									success : function(data) {
										eval('data=' + data);
										if (data.success) {
											grid.datagrid('reload');
										} else {
											sys_alert('错误提示', data.msg, 'error');
										}
									}
								});
					} else {
						sys_alert('错误提示', '选择一个收款单', 'error');
					}

				}
			});

}
function closeWindow() {
	win.window('close');
	greyLayer.close();
}